package de.dfki.asr.genesis2.sms.util;

import java.util.ArrayList;

import org.json.JSONObject;

public abstract class SocialPOIXMLExtractor {	
	
	public SocialPOIXML parseJSON(JSONObject jsonObj) {
		
		Location location = extractLocation(jsonObj);
		
		SocialEvent socialEvent = new SocialEvent();
		
		//socialEvent.setId(extractId(jsonObj));
		//socialEvent.setTimestamp(extractTimestamp(jsonObj));
		//socialEvent.setDescription(extractDescription(jsonObj));
		//socialEvent.setTitle(extractLabel(jsonObj));
		//socialEvent.setUrl(extractUrl(jsonObj));
		socialEvent.setFrom(extractFrom(jsonObj));
		socialEvent.setKeywords(extractKeywords(jsonObj));	
		socialEvent.setMessage(extractMessage(jsonObj));
		socialEvent.setTagList(extractTagList(jsonObj));
		socialEvent.setToList(extractToList(jsonObj));
		socialEvent.setSource(extractSource(jsonObj));
		socialEvent.setMediaContent(extractMediaContent(jsonObj));
		socialEvent.setMediaThumbnail(extractMediaThumbnail(jsonObj));
		
		SocialPOIXML poi = new SocialPOIXML();
		poi.setId(extractId(jsonObj));
		poi.setLabel(extractLabel(jsonObj));
		poi.setDescription(extractDescription(jsonObj));
		poi.setLink(extractLink(jsonObj));
		poi.setTime(extractTimestamp(jsonObj));
		poi.setLocation(location);
		poi.setSocialEvent(socialEvent);
		
		return poi;
	}
	
	public String extractPOIXML(JSONObject jsonObj) {
		return parseJSON(jsonObj).toString();		
	}
	
	public String extractPOIXMLsFromResponse(String body) {
		return extractPOIXMLsFromResponse(body, Integer.MAX_VALUE);
	}
	
	public abstract String extractPOIXMLsFromResponse(String body, int maxResults);
	
	public abstract String extractId(JSONObject jsonObj);
	
	public abstract Point extractPoint(JSONObject jsonObj);
	
	public abstract Location extractLocation(JSONObject jsonObj);
	
	public abstract String extractLabel(JSONObject jsonObj);
	
	public abstract String extractMessage(JSONObject jsonObj);
	
	public abstract String extractDescription(JSONObject jsonObj);
	
	public abstract User extractFrom(JSONObject jsonObj);
	
	public abstract ArrayList<User> extractToList(JSONObject jsonObj);
	
	public abstract ArrayList<TaggedUser> extractTagList(JSONObject jsonObj);
	
	public abstract String extractKeywords(JSONObject jsonObj);
	
	public abstract String extractUrl(JSONObject jsonObj);
	
	public abstract Link extractLink(JSONObject jsonObj);
	
	public abstract String extractAction(JSONObject jsonObj);
	
	public abstract long extractTimestamp(JSONObject jsonObj);
	
	public abstract String extractSource(JSONObject jsonObj); 
	
	public abstract Media extractMediaContent(JSONObject jsonObj);
	
	public abstract Media extractMediaThumbnail(JSONObject jsonObj);
}
